#ifndef SERVERCONNECTOR_H
#define SERVERCONNECTOR_H

#include <QObject>
#include <QTcpSocket>

class ServerConnector : public QObject
{
    Q_OBJECT
public:
    static ServerConnector& getInstance();

    ServerConnector(ServerConnector&) = delete;
    ServerConnector& operator=(const ServerConnector&) = delete;

private:
    static ServerConnector m_instance;
    QTcpSocket* m_socket = nullptr;

    explicit ServerConnector(QObject *parent = nullptr);
    ~ServerConnector();


public slots:
    void connectToServer();

    void onConnected();
    void onErrorOccurred(QAbstractSocket::SocketError);
    void onDataReceived();
    void onDisconnected();

    void sendData(QByteArray);


signals:
    void ConnectionStatusChanged(bool, QString);

    void sendOriginData(QByteArray originData);
};

#endif // SERVERCONNECTOR_H
